#include<bits/stdc++.h>
#define N 5500000
#define eps 1e-7
#define inf 1e9+7
#define db double
#define ll long long
#define ldb long double
using namespace std;
inline int read()
{
	char ch=0;
	int x=0,flag=1;
	while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*flag;
}
int n,k,mo,ans,a[N],s[N],v[N];
int ksm(int x,int k)
{
	int ans=1;
	while(k){if(k&1)ans=1ll*ans*x%mo;k>>=1;x=1ll*x*x%mo;}
	return ans;
}
int inv(int x){return ksm((x%mo+mo)%mo,mo-2);}
int main()
{
	n=read();mo=read();k=read(); 
	s[0]=1;for(int i=1;i<=n;i++)a[i]=read(),s[i]=1ll*s[i-1]*a[i]%mo;
	v[n]=inv(s[n]);for(int i=n-1;i>=0;i--)v[i]=1ll*v[i+1]*a[i+1]%mo;
	for(int i=1,t=k;i<=n;i++,t=1ll*t*k%mo)ans=(ans+1ll*t*s[i-1]%mo*v[i]%mo)%mo;
	printf("%d",ans);
	return 0;
}
